package com.njmt.cloud.msprovder.controller;

import com.njmt.cloud.msprovder.service.UserService;
import com.njwt.cloud.mscommon.pojo.bo.UserBo;
import com.njwt.cloud.mscommon.support.ApiResponse;
import com.njwt.cloud.mscommon.support.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author <a href="mailto:xingxiaofeng@gtmap.cn">xingxiaofeng</a>
 * @date 2022-06-21
 * @desc UsersController
 */
@RestController
@RequestMapping("user")
public class UsersController extends BaseController{
    private final static Logger logger = LoggerFactory.getLogger(UsersController.class);

    @Autowired
    private UserService userService;

    @GetMapping("/api/{username}")
    public ApiResponse getUserByUserName(@PathVariable(value = "username") String username) {
        UserBo userEntity = userService.loadUserByUserName(username);
        logger.info("02:36.01 /var/log/Service1/myapp.log Ruby is great");
         return super.success(userEntity);
    }
    @GetMapping("/user/info/{id}")
    public ApiResponse loadUserByUserId(@PathVariable(value="id") String id){
          return super.success( userService.loadUserById(id));
    }
}
